package com.qingcheng.controller;

import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@RequestMapping("/redirect")
public class RedirectController {

    @GetMapping("/back")
    public String redirect(@RequestHeader(value = "Referer", required = false) String referer) {
        if (!StringUtils.isEmpty(referer))
            //Referer: http://localhost:9104/seckill-item.html?time=2019082418&id=14
            return "redirect:" + referer;
                //redirect:http://localhost:9104/seckill-item.html?time=2019082418&id=14

        return "redirect:/seckill-index.html";
    }
}
